﻿using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace Koonsoft.HYCRM.DAL
{
    public class RegionDAL
    {
        private static readonly Database database = DatabaseFactory.CreateDatabase("KOONCRMDB");

        /// <summary>
        /// 根据注册地ID获取区域名称
        /// </summary>
        /// <param name="regionID"></param>
        /// <returns></returns>
        public string GetRegionNameByRegionID(int regionID)
        {
            const string sql = "select regionname from region where regionid=@regionid";

            using(var cmd = database.GetSqlStringCommand(sql))
            {
                database.AddInParameter(cmd, "@regionid", DbType.Int32, regionID);

                return database.ExecuteScalar(cmd).ToString();
            }
        }
    }
}
